/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package components;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Ragnar
 */
public class MyCellRenderer extends DefaultTableCellRenderer
{
    private NTable parent;
    private Color mover2 = new Color(231,251,176);
    private Color oddrows = new Color(202,252,91);

    public MyCellRenderer(NTable parent)
    {
        this.parent = parent;
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
    {
        Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        int val = Integer.parseInt(table.getModel().getValueAt(row, 3).toString());
        
        if (val < 10)
        {
            comp.setBackground(new Color(255, 150, 150));
        }
        else
        {
            if (parent.getRovv() == row)
            {
                comp.setBackground(this.oddrows);
            }
            else
            {
                if (row % 2 == 0 && !table.isCellSelected(row, column)) 
                {
                    comp.setBackground(Color.white);
                } 
                else 
                {
                    comp.setBackground(this.mover2);
                }
            }
        }
        return comp;
    }
}
